home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / graphics / flick_12.zip / C2P_CMP.S < prev    next >
Text File  |  1994-02-18  |  7KB  |  332 lines

  1. ;
  2. ;        Flick FLI-format Animation Viewer v1.2          19 Feb 1994
  3. ;        --------------------------------------
  4. ;
  5. ;
  6. ;This program plays FLI/FLC-format bitmapped animation files on any ECS
  7. ;or AGA Amiga running OS2.04 or higher.  FLI/FLC-format files are
  8. ;produced by Autodesk Animator and Autodesk 3D Studio on a PC, as well
  9. ;as by other programs.
  10. ;
  11. ;The files in this archive may be distributed anywhere provided they are
  12. ;unmodified and are not sold for profit.
  13. ;
  14. ;Ownership and copyright of all files remains with the author:
  15. ;
  16. ;    Peter McGavin, 86 Totara Crescent, Lower Hutt, New Zealand.
  17. ;    e-mail: peterm@maths.grace.cri.nz
  18. ;
  19. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  20. ;        xdef    _chunky2planar
  21.  
  22. ; Basically the same as peterm/chunky4.s, except compare chunky memory
  23. ; with a compare page and update only where changes occur.
  24. ; Also update the compare page.
  25.  
  26. ;-----------------------------------------------------------------------------
  27. ; Set Macro68 defaults
  28.  
  29.         default    _branch,_word
  30.         default    _adrbasedisp,_word
  31.         default    _pcbasedisp,_word
  32.         default    _outerdisp,_word
  33.         default    _absolute,_pcrel
  34.  
  35. ;-----------------------------------------------------------------------------
  36. ; chunky2planar:    (new Motorola syntax)
  37. ;  a0 -> chunky pixels
  38. ;  a1 -> plane0 (assume other 7 planes are allocated contiguously)
  39. ;  a2 -> compare page of chunky pixels
  40. ;  d1 = width*height/32 (if "generic" is defined)
  41.  
  42.  
  43.     ifnd generic
  44. plsiz        equ    width*height/8
  45.     endc
  46.  
  47.  
  48. _LVOCacheClearU equ    -636
  49.  
  50.     ifd generic
  51.     ifeq depth-8
  52. _c2p_8_cmp::
  53.     else
  54.     ifeq depth-6
  55. _c2p_6_cmp::
  56.     else
  57.     ifeq depth-4
  58. _c2p_4_cmp::
  59.     endc
  60.     endc
  61.     endc
  62.     else
  63.     ifeq depth-8
  64.         ifeq    width-320
  65. _c2p320x200x8_cmp::
  66.         endc
  67.     else
  68.     ifeq depth-6
  69.         ifeq    width-320
  70. _c2p320x200x6_cmp::
  71.         endc
  72.     else
  73.         die    "Unrecognised resolution"
  74.     endc
  75.     endc
  76.     endc
  77.  
  78.         movem.l    d2-d7/a2-a6,-(sp)
  79.  
  80.         bset    #0,(firsttimeflag)
  81.         bne.b    skip_relocate    ; branch if not being called 1st time
  82.  
  83. ; relocate the mainloop to a quad-longword boundary (for 030/040 cache line)
  84.  
  85.         lea    (begincode,pc),a4
  86.         adda.w    #15,a4
  87.         move.l    a4,d0
  88.         and.w    #~15,d0
  89.         movea.l    d0,a4
  90.         lea    (mainloop,pc),a3
  91.         move.w    #(endcode-mainloop)/2-1,d0
  92. 1$:        move.w    (a3)+,(a4)+
  93.         dbra    d0,1$
  94.  
  95. ; flush the caches
  96.  
  97.         movem.l    a0/a1/d1,-(sp)
  98.         movea.l    (4).w,a6
  99.         jsr    (_LVOCacheClearU,a6)
  100.         movem.l    (sp)+,a0/a1/d1
  101.  
  102. skip_relocate:    move.w    sp,d0
  103.         and.w    #15,d0
  104.         add.w    #32,d0        ; make room on stack for
  105.         suba.w    d0,sp        ; 32-byte quad-longword aligned buffer
  106.         movea.l    sp,a3        ; pointed to by a3
  107.         move.w    d0,-(sp)    ; and save the allocated size
  108.     ifd generic
  109.         move.l    d1,-(sp)    ; plsiz on stack at (6,sp)
  110.         move.l    d1,d0
  111.     ifeq depth-8
  112.         lsl.l    #3,d0
  113.         sub.l    d1,d0        ; d0 = 7*plsiz
  114.     else
  115.     ifeq depth-6
  116.         lsl.l    #2,d0
  117.         add.l    d1,d0        ; d0 = 5*plsiz
  118.     else
  119.     ifeq depth-4
  120.         add.l    d0,d0
  121.         add.l    d1,d0        ; d0 = 3*plsiz
  122.     else
  123.         die    "Unsupported depth"
  124.     endc
  125.     endc
  126.     endc
  127.         move.l    d0,-(sp)    ; (depth-1)*plsiz on stack at (2,sp)
  128.         lsr.l    #2,d1
  129.         move.w    d1,-(sp)    ; outer loop counter on stack at (sp)
  130.     else
  131.         move.w    #plsiz/4,-(sp)    ; outer loop counter on stack at (sp)
  132.     endc
  133.  
  134. ; set up register constants
  135.  
  136.         move.l    #$0f0f0f0f,d5    ; d5 = constant $0f0f0f0f
  137.         move.l    #$55555555,d6    ; d6 = constant $55555555
  138.         move.l    #$3333cccc,d7    ; d7 = constant $3333cccc
  139.  
  140. ; load up address registers with buffer ptrs
  141.  
  142.         lea    (2*4,a3),a4    ; a4 -> plane2buf
  143.     ifgt depth-4
  144.         lea    (2*4,a4),a5    ; a5 -> plane4buf
  145.     endc
  146.         lea    (4,a3),a6    ; a6 used for inner loop end test
  147.  
  148. begincode:    rept    8        ; space for mainloop code relocation
  149.         nop
  150.         endr
  151.  
  152. ; main loop (starts here) processes 32 chunky pixels at a time
  153. ; compare next 32 pixels with compare page, looking for differences
  154.  
  155. mainloop:    cmpm.l    (a0)+,(a2)+
  156.         bne.b    1$
  157.         cmpm.l    (a0)+,(a2)+
  158.         bne.b    2$
  159.         cmpm.l    (a0)+,(a2)+
  160.         bne.b    3$
  161.         cmpm.l    (a0)+,(a2)+
  162.         bne.b    4$
  163.         cmpm.l    (a0)+,(a2)+
  164.         bne.b    5$
  165.         cmpm.l    (a0)+,(a2)+
  166.         bne.b    6$
  167.         cmpm.l    (a0)+,(a2)+
  168.         bne.b    7$
  169.         cmpm.l    (a0)+,(a2)+
  170.         bne.b    8$
  171.  
  172.         addq.l    #4,a1        ; skip 4 bytes in output
  173.         sub.w    #1,(sp)
  174.         bne.b    mainloop
  175.         bra.w    done
  176.  
  177. ; difference found, restore a0 and a2
  178.  
  179. 8$:        subq.l    #4,a0
  180.         subq.l    #4,a2
  181. 7$:        sub.w    #28,a0
  182.         sub.w    #28,a2
  183.         bra.b    go_c2p
  184.  
  185. 6$:        subq.l    #4,a0
  186.         subq.l    #4,a2
  187. 5$:        sub.w    #20,a0
  188.         sub.w    #20,a2
  189.         bra.b    go_c2p
  190.  
  191. 4$:        subq.l    #4,a0
  192.         subq.l    #4,a2
  193. 3$:        sub.w    #12,a0
  194.         sub.w    #12,a2
  195.         bra.b    go_c2p
  196.  
  197. 2$:        subq.l    #4,a0
  198.         subq.l    #4,a2
  199. 1$:        subq.l    #4,a0
  200.         subq.l    #4,a2
  201.  
  202. ; convert 32 pixels to stack buffers
  203.  
  204. go_c2p:        move.l    (a0)+,d2    ; 12 get next 4 chunky pixels in d2
  205.         move.l    d2,(a2)+    ;    update compare page
  206.         move.l    (a0)+,d3    ; 12 get next 4 chunky pixels in d3
  207.         move.l    d3,(a2)+    ;    update compare page
  208.     ifgt depth-4
  209.         move.l    d2,d0        ;  4
  210.         and.l    d5,d2        ;  8 d5=$0f0f0f0f
  211.         move.l    d3,d1        ;  4
  212.         and.l    d5,d3        ;  8 d5=$0f0f0f0f
  213.         eor.l    d2,d0        ;  8
  214.         eor.l    d3,d1        ;  8
  215.         lsr.l    #4,d1        ; 16
  216.         or.l    d1,d0        ;  8
  217.     endc
  218.         lsl.l    #4,d2        ; 16
  219.         or.l    d3,d2        ;  8
  220.         move.l    d2,d3        ;  4
  221.         and.l    d7,d3        ;  8 d7=$3333cccc
  222.         eor.l    d3,d2        ;  8
  223.         lsr.w    #2,d3        ; 10
  224.         swap    d3        ;  4
  225.         lsl.w    #2,d3        ; 10
  226.         or.l    d2,d3        ;  8
  227.     ifgt depth-4
  228.         move.l    d0,d1        ;  4
  229.         and.l    d7,d1        ;  8 d7=$3333cccc
  230.         eor.l    d1,d0        ;  8
  231.         lsr.w    #2,d1        ; 10
  232.         swap    d1        ;  4
  233.         lsl.w    #2,d1        ; 10
  234.         or.l    d0,d1        ;  8
  235.         move.l    d1,d2        ;  4
  236.         lsr.l    #7,d2        ; 22
  237.         move.l    d1,d0        ;  4
  238.         and.l    d6,d0        ;  8 d6=$55555555
  239.         eor.l    d0,d1        ;  8
  240.         move.l    d2,d4        ;  4
  241.         and.l    d6,d4        ;  8 d6=$55555555
  242.         eor.l    d4,d2        ;  8
  243.         or.l    d4,d1        ;  8
  244.         lsr.l    #1,d1        ; 10
  245.         move.b    d1,(4,a5)    ; 12 plane 5
  246.     ifgt depth-6
  247.         swap    d1        ;  4
  248.         move.b    d1,(12,a5)    ; 12 plane 7
  249.     endc
  250.         or.l    d0,d2        ;  8
  251.         move.b    d2,(a5)+    ;  8 plane 4
  252.     ifgt depth-6
  253.         swap    d2        ;  4
  254.         move.b    d2,(8-1,a5)    ;  8 plane 6
  255.     endc
  256.     endc
  257.         move.l    d3,d2        ;  4
  258.         lsr.l    #7,d2        ; 22
  259.         move.l    d3,d0        ;  4
  260.         and.l    d6,d0        ;  8 d6=$55555555
  261.         eor.l    d0,d3        ;  8
  262.         move.l    d2,d4        ;  4
  263.         and.l    d6,d4        ;  8 d6=$55555555
  264.         eor.l    d4,d2        ;  8
  265.         or.l    d4,d3        ;  8
  266.         lsr.l    #1,d3        ; 10
  267.         move.b    d3,(4,a3)    ; 12 plane 1
  268.         swap    d3        ;  4
  269.         move.b    d3,(4,a4)    ; 12 plane 3
  270.         or.l    d0,d2        ;  8
  271.         move.b    d2,(a3)+    ;  8 plane 0
  272.         swap    d2        ;  4
  273.         move.b    d2,(a4)+    ;  8 plane 2
  274.  
  275.         cmpa.l    a3,a6
  276.         bne.w    go_c2p
  277.  
  278. ; move the result of the previous 32 pixels from stack buffers to
  279. ; chip ram planes and restore stack buffer pointers
  280.  
  281.     ifd generic
  282.         adda.l    (2,sp),a1        ; add (depth-1)*plsiz
  283.         move.l    (6,sp),d0        ; plsiz
  284.     else
  285.         adda.l    #(plsiz*(depth-1)),a1
  286.         move.l    #plsiz,d0
  287.     endc
  288.     ifgt depth-6
  289.         move.l    (8,a5),(a1)        ; plane 7
  290.         sub.l    d0,a1
  291.         move.l    (4,a5),(a1)        ; plane 6
  292.         sub.l    d0,a1
  293.     endc
  294.     ifgt depth-4
  295.         move.l    (a5),(a1)        ; plane 5
  296.         sub.l    d0,a1
  297.         move.l    -(a5),(a1)        ; plane 4
  298.         sub.l    d0,a1
  299.     endc
  300.         move.l    (a4),(a1)        ; plane 3
  301.         sub.l    d0,a1
  302.         move.l    -(a4),(a1)        ; plane 2
  303.         sub.l    d0,a1
  304.         move.l    (a3),(a1)        ; plane 1
  305.         sub.l    d0,a1
  306.         move.l    -(a3),(a1)+        ; plane 0
  307.  
  308. ; check if finished
  309.  
  310. check_done:    sub.w    #1,(sp)
  311.         bne.w    mainloop
  312.  
  313. ; all done!  restore stack and return
  314.  
  315. done:    ifd generic
  316.         adda.w    #4+4+2,sp        ; remove stack variables
  317.     else
  318.         addq.w    #2,sp            ; remove outer loop counter
  319.     endc
  320.         adda.w    (sp)+,sp        ; remove aligned 32-byte buffer
  321.         movem.l    (sp)+,d2-d7/a2-a6
  322.  
  323.         rts
  324. endcode:
  325.  
  326. firsttimeflag:    dc.b    0
  327.         even
  328.  
  329. ;-----------------------------------------------------------------------------
  330.  
  331.         end
  332.